using System.Collections;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Tools;

namespace ctsu.Admin.BusLogic
{
	public class FormDockingManager
	{
		private DockingManager _dockManager;
		public FormDockingManager(DockingManager dockManager)
		{
			this._dockManager = dockManager;
		}

		public bool DockControlExists(string name)
		{
			IEnumerator ien = _dockManager.Controls;
			while (ien.MoveNext())
			{
				Control ctl = (Control)ien.Current;
				if (ctl.Name == name)
					return true;
			}
			return false;
		}

		public Control GetDockControl(string name)
		{
			IEnumerator ien = _dockManager.Controls;
			while (ien.MoveNext())
			{
				Control ctl = (Control)ien.Current;
				if (ctl.Name == name)
					return ctl;
			}
			return null;
		}

		public bool IsDockControlVisible(string name)
		{
			Control control = GetDockControl(name);
			if (control == null)
				return false;
			else
				return IsDockControlVisible(control);
		}

		public bool IsDockControlVisible(Control control)
		{
			if (_dockManager.GetDockVisibility(control))
				return true;
			else
				return false;
		}

		public void ActivateDockControl(string name)
		{
			Control ctl = GetDockControl(name);
			if (ctl != null)
			{
				if (!IsDockControlVisible(ctl))
					SetDockControlVisibility(ctl, true);
				_dockManager.ActivateControl(ctl);
			}
		}

		public void SetDockControlVisibility(string name, bool setVisible)
		{
			Control control = GetDockControl(name);
			if (control != null)
				SetDockControlVisibility(control, setVisible);

		}

		public void SetDockControlVisibility(Control ctl, bool setVisible)
		{
			if (setVisible)
			{
				if (_dockManager.GetDockVisibility(ctl) == false)
					_dockManager.SetDockVisibility(ctl, true);
			}
			else
			{
				if (_dockManager.GetDockVisibility(ctl) == true)
					_dockManager.SetDockVisibility(ctl, false);
			}
		}

	}
}
